<?
include("gestione/includes/config.inc.php");
include("gestione/includes/auth.lib.php");
include("gestione/includes/function.inc.php");
include("gestione/includes/product_new.class.php");
include("gestione/includes/e-commerce_new.class.php");
include("gestione/includes/news.class.php");
include("gestione/includes/content.class.php");
include("gestione/includes/keywords.class.php");
include("gestione/includes/class.xml.php");
$lang = "ita";
####################### DEFAULT PISCINE #######################################################
$cid = 2;
$tiponews = "piscine";
$titvetrina = "tit-articoli-piscine-vetrina.gif";
$titcontent = "bkgTitCnt_piscine.gif";
$tipobanner = "piscine";
$titprodotti = '<img src="/images/titoli/tit-prodotti-piscine.gif" width="240" height="55">';
$titnovita = '<img src="/images/titoli/tit-novita-piscine.gif" width="200" height="55">';
$logo = '<img src="/images/loghi/bs-piscine.gif" width="99" height="100">';
$bgcolor = '#00A6E9';
####################### SESSION ##############################################################
$newSession = new websession();
if($newSession->order != NULL) {
  	$articoli = $newSession->order->getArticoli();
  	if(count($articoli)>0) {
  	 $tot = $newSession->order->getTotale($articoli);
  	 if($newSession->order->idbuono > 0) $tot-=$newSession->order->buono;
  	 $str_tot = "&nbsp;TOTALE: &euro; ".number_format($tot,2,",",".");
  	}
}
if($newSession->getStatus())  {
  $registrati = '<a href="/webproduct.php?op=logout" rel="nofollow"><img src="/images/logout.png"></a><br><br>
  <a href="/webproduct.php?op=profile" rel="nofollow"><img src="/images/profilo.png"></a>';
  $tablelogin = '';
 }
####################################################################################################
$op = $_GET['op'];
if($op == "")
 $op = $_POST['op'];
$content = '<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
						  <td width="20"><img src="/images/spacer.gif" width="20" height="36"></td>
						  <td width="470" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="3" class=plain>									
						  <tr>
			  <td width=100% class=tit01>Testimonianze dei nostri clienti</td>
			</tr>';
  switch($op)  {
    case "addFeed":
	  $content .= '<tr>
			  <td width=100% align=center>
				<table width=650 cellpadding=3 cellspacing=0 class=plain style="border:1px #EFEFEF solid">
				 <tr>
				  <td class=tit02 align=center>Lascia il tuo commento</td>
				 </tr>
				 <tr>
				  <td width=100%>
					<table width=650 class=plain cellpadding=3 cellspacing=0>
					   <form name=formfeed action=feedback.php method=POST>						
						<tr>
						 <td colspan=2>&nbsp;</td>
						</tr>
						<tr>
						 <td width=60 align=right>Nome:</td>
						 <td><input type=text id=name name=name value="'.$newSession->webuser->ragione.'"  size=50></td>
						</tr>
						<tr>
						 <td width=60 align=right valign=top>Giudizio:</td>
						 <td>
						 <table width=40>
						  <tr>
						   <td width=20><input type=radio name=voto value=negativo></td>
						   <td width=20><img src="/images/iconNeg_16x16.gif" alt=Negativo></td>
						  </tr>
						  <tr> 
						   <td width=20><input type=radio name=voto value=neutro></td>
						   <td width=20><img src="/images/iconNeu_16x16.gif" alt=Neutro></td>
						  </tr>
						  <tr> 
						   <td width=20><input type=radio name=voto value=positivo></td>
						   <td width=20><img src="/images/iconPos_16x16.gif" alt=Positivo></td>
						  </tr> 
						 </table>
						</tr>
						<tr>
						 <td align=right valign=top>Commento:</td>
						 <td valign=top><textarea id=testo name=testo cols=80 rows=10></textarea></td>
						</tr>
						<tr>
						 <td colspan=2>&nbsp;<input type=hidden name=op value=save>
						 </td>
						</tr>
						<tr>
						 <td colspan=2 align=center><input type=submit value=Invia onClick="return check_Voto();"></td>
						</tr>
						</form>
						</table>
				  </td>
				 </tr>
				</table>
			  </td>
			</tr>';
	break;
	
	case "save":
	 	$voto = $_POST['voto'];
		$testo = $_POST['testo'];
		$name = $_POST['name'];
		$feed = new feedback("",$name,0,$voto,$testo);
		$error = $feed->save();
		$content .= "<tr>
			  		<td width=100% align=center>
			    		<table width=650 border=0 cellpadding=0 cellspacing=0>
							<tr>
							 <td width=650 valign=top>
							  <table class=plain width=650 cellpadding=2><tr><td class=error align=\"center\"><b>$error</b><br><a class=plain href=\"feedback.php\">Guarda tutti i commenti</a></td>
							  </tr>
							  </table>
							  </td>
							</tr>
						</table>
					   </td>
						</tr>";
	break;
	
	default:
		$min = $_GET['min'];
		$max = $_GET['max'];
		$page = $_GET['page'];
		$tipo = $_GET['tipo'];
	  $thismonth = date("m");
	  		$jschart = 'var data = [
		{ label: "Positivo",  data: '.feedback::getStat("positivo","this").', color: "#007A0C"},
		{ label: "Neutro",  data: '.feedback::getStat("neutro","this").', color: "#5E8BC0"},
		{ label: "Negativo",  data: '.feedback::getStat("negativo","this").', color: "#F97A7A"}
	];
	$.plot($("#chart_1mese"), data, 
	{
		series: {
			pie: { 
				show: true//,
				/*
				label: {
                    show: true,
                    radius: 3/4,
                    formatter: function(label, series){
                        return \'<div style="font-size:12px;text-align:center;padding:2px;">\'+label+\'<br/>\'+Math.round(series.percent)+\'%</div>\';
                    }
                }*/
			}
		},
		legend: {
			show: false
		}
	});
	var data = [
		{ label: "Positivo",  data: '.feedback::getStat("positivo","last6").', color: "#007A0C"},
		{ label: "Neutro",  data: '.feedback::getStat("neutro","last6").', color: "#5E8BC0"},
		{ label: "Negativo",  data: '.feedback::getStat("negativo","last6").', color: "#F97A7A"}
	];
	$.plot($("#chart_6mese"), data, 
	{
		series: {
			pie: { 
				show: true
			}
		},
		legend: {
			show: false
		}
	});
	var data = [
		{ label: "Positivo",  data: '.feedback::getStat("positivo","tot").', color: "#007A0C"},
		{ label: "Neutro",  data: '.feedback::getStat("neutro","tot").', color: "#5E8BC0"},
		{ label: "Negativo",  data: '.feedback::getStat("negativo","tot").', color: "#F97A7A"}
	];
	$.plot($("#chart_totale"), data, 
	{
		series: {
			pie: { 
				show: true
			}
		},
		legend: {
			show: false
		}
	});';
			$content .= '<tr>
			  <td width=100% align=center>
				<table width=650 cellpadding=3 cellspacing=0 class=plain style="border:1px #EFEFEF solid">
				 <tr>
				  <td colspan=3 class=tit02 align=center>Indice di gradimento</td>
				 </tr>
				 <tr>
				  <td width=210 align=center><div style="text-align:center;font-size:14px;font-weight:bold;">'.$mesi[$thismonth].'</div><div id="chart_1mese" class="graph" style="height:300px;"></div></td>
				  <td width=210 align=center><div style="text-align:center;font-size:14px;font-weight:bold;">Ultimi 6 mesi</div><div id="chart_6mese" class="graph" style="height:300px;"></div></td>
				  <td width=210 align=center><div style="text-align:center;font-size:14px;font-weight:bold;">Totale</div><div id="chart_totale" class="graph" style="height:300px;"></div></td>
				 </tr>
				</table>
			  </td>
			</tr>
			<tr>
			 <td width=100% align=center>
			  <a class=plain href="feedback.php?op=addFeed" style="font-size:14px;font-weight:bold;">Lascia un commento di feedback</a>
			 </td>
			</tr>
				 <tr>
					<td width=100% align=center>'.feedback::getFeedback("plain",$tipo,$min,$max,$page).'</td>
				 </tr>';
	break;
  }
  $content .= '</table>                      
			 </td>
			 <td width="20"><img src="/images/spacer.gif" width="20" height="36"></td>
						</tr>
					</table>';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?include("includes/header.php");?>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-2773334-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>

<body>
<div class="contenitore">
<div id="importante">
   <div id="contenuto" style="margin:10px; width:690px;">
   <?=$content?>
   </div>
   <div id="left">
   <?include("includes/col-left.php")?>
   </div>
</div>
<?php /*
<div id="right">
<?include("includes/col-right.php")?>
</div>
*/ ?>
<div id="header">
<?include("includes/top.php")?>
</div>
<div id="footer">
<?include("includes/footer.php")?>
</div>
</div>
</body>
</html>